<?php

namespace app\api\controller;

use app\admin\model\ArticleModel;
use app\common\controller\Api;


class Article extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    /**
     * @var ArticleModel
     */
    protected $model = null;

    public function _initialize()
    {
        parent::_initialize();
        $this->model = new ArticleModel();
    }

    public function index()
    {
        $list = $this->model
            ->field('id,title,create_time,update_time')
            ->order('id', 'desc')
            ->paginate(15);

        $this->success('请求成功', $list);
    }

    public function detail()
    {
        $id = $this->request->get('id/d', 0);
        $row = $this->model->find($id);
        $this->success('success', $row);
    }
}
